package com.yfjin.merge;

import android.os.Bundle;
import android.os.Environment;
import android.util.Log;

import java.io.File;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    //10-20秒
                    merge();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }).start();

    }

    private void merge() throws Exception {


        File videoFile = new File(Environment.getExternalStorageDirectory(), "input.mp4");
        if (!videoFile.exists()) {
            Log.i("123123", "videoFile bucunzai");
            return;
        }


        final File audioFile = new File(Environment.getExternalStorageDirectory(), "music.mp3");
        if (!audioFile.exists()) {
            Log.i("123123", "audioFile bucunzai");
            return;
        }


        File outPutFile=new File(Environment.getExternalStorageDirectory(), "out.mp4");

        //音量
        int videoVolume = 0;
        int audioVolume = 0;

        new MusicProgress().mixAudioTrack(this
                , videoFile.getAbsolutePath()
                , audioFile.getAbsolutePath()
                , outPutFile.getAbsolutePath()
                , videoVolume, audioVolume
        );
    }

}